import axios from '@/libs/api.request'
import apiurl from './apiurl'

// 登陆
const login = (data = { email, password }) => {
  return axios.request({
    url: apiurl.login,
    method: 'post',
    data
  })
}

// 注册
const register = (data = { username, eamil, password }) => {
  return axios.request({
    url: apiurl.register,
    method: 'post',
    data
  })
}

const getUsers = (params = { page, pageSize, username, eamil }) => {
  return axios.request({
    url: apiurl.getUsers,
    method: 'get',
    params
  })
}

const updatePwd = (data = { id, passwrod }) => {
  return axios.request({
    url: apiurl.updatePwd,
    method: 'post',
    data
  })
}

const deleteUser = id => {
  return axios.request({
    url: apiurl.deleteUser + `/${id}`,
    method: 'get'
  })
}

const getUserInfo = email => {
  return axios.request({
    url: apiurl.getUserInfo,
    method: 'get',
    params: { email }
  })
}

export default {
  login,
  register,
  getUsers,
  updatePwd,
  deleteUser,
  getUserInfo
}
